import configparser
import os

root_path = os.path.dirname(os.path.abspath(__file__))

class Config(configparser.ConfigParser):
    def __init__(self, defaults=None):
        configparser.ConfigParser.__init__(self, defaults=defaults)

    def optionxform(self, optionstr):
        return optionstr
    
config = Config()

config.read(os.path.join(root_path, 'database.ini'))
infer_username = config.get('mysql_infer', 'username')
infer_password = config.get('mysql_infer', 'password')
infer_url = config.get('mysql_infer', 'url')
infer_port = config.get('mysql_infer', 'port')
infer_db = config.get('mysql_infer', 'db')

web_username = config.get('mysql_web', 'username')
web_password = config.get('mysql_web', 'password')
web_url = config.get('mysql_web', 'url')
web_port = config.get('mysql_web', 'port')
web_db = config.get('mysql_web', 'db')


config.read(os.path.join(root_path, 'server.ini'))
scp_type = config.getint('lot', 'scp_type')
scp_interval = config.getint('lot', 'scp_interval')
infer_type = config.getint('lot', 'infer_type')
delete_passwd = config.get('lot', 'delete_passwd')
date_today = config.get('lot', 'date_today')
data_volume = config.get('lot', 'data_volume')
ai_machine = config.get('lot', 'ai_machine')
scp_ip = config.get('lot', 'scp_ip')

ctype = config.getint('clear', 'ctype')
clear_size = config.getint('clear', 'clear_size')
clear_day = config.getint('clear', 'clear_day')
log_dir = config.get('clear', 'log_dir')

config = Config()
config.read(os.path.join(root_path, 'parameter.ini'))
# 读取所有参数
all_parameter = {}

for section in config.sections():
    all_parameter[section] = dict(config.items(section))


thumb_dir =f"{data_volume}/oqc/thumb"
# lot_upload_dir =f"{data_volume}/oqc/upload"
lot_upload_dir ="/nfs2/algorithm/xh/OQC/test_Data"
out_dir =f"{data_volume}/oqc/output"
export_dir =f"{data_volume}/oqc/export"
csv_dir =f"{data_volume}/oqc/csv"
material_dir =f"{data_volume}/oqc/material"
lot_dir =f"{data_volume}/oqc/lot"

yolox_model_path1 = f"{data_volume}/qatmodels_release/black2_v1.0.3.425/YOLOXQAT.xmodel"
yolox_model_path2 = f"{data_volume}/qatmodels_release/div_v1.0.3.425/YOLOXQAT.xmodel"
yolox_model_path3 = f"{data_volume}/qatmodels_release/rgbw_v1.0.3.425/YOLOXQAT.xmodel"
cls_forWhite_model_path = f"{data_volume}/qatmodels_release/classification_white_v1.0.1.417/ImageClassifierQAT.xmodel"
cls_forRules_model_path = f"{data_volume}/qatmodels_release/classification_yiwu_v1.0.2.421/Resnet18QAT.xmodel"

thread_num = 2

jd_package = "pip/jd_package_oqc-1.0.9-py3-none-any.whl"